#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<fcntl.h>


int main()
{
    int fd = open("name_pipe_file", O_RDWR | O_APPEND);
    if (fd < 0) perror("open name_pipe_file fail"), exit(0);

    //receive message from name_pipe
    while(true)
    {
        char buff[1024];
        int n = read(fd, buff, sizeof(buff));
        if (n < 0) perror("read fail"), exit(0);
        fprintf(stdout, "%s\n", buff);
        sprintf(buff, "%s", "YES, this's process B, I can receive your message");
        fprintf(stdout, "%s\n", buff);
        printf("\n");
    }
    return 0;
}